<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>PDF文件管理</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link rel="stylesheet" type="text/css" href="css/easyui.css">
	<link rel="stylesheet" type="text/css" href="css/icon.css">
	<!-- <link rel="stylesheet" type="text/css" href="css/demo.css"> -->
	<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
	<script type="text/javascript">
		function deleteFile(){
			if($("#tt2").find("input").length==0){
				alert('请先选择要删除的文件');
				return;
			}
			var count=0;
			var nodes = new Array();
			var ids = new Array();
			var values = new Array();
			var node;
			$("#tt2").find("input").each(function(){
				if($(this).prop('checked')){
					count++;
					node = $('#tt2').tree('find',$(this).attr("id"));
					nodes.push(node);
					ids.push(node.id);
					values.push($(this).val());
					//$('#tt2').tree('remove', node.target);
					//alert($(this).val());
				}
			});
			if(count==0){
				alert('请先选择要删除的文件');
			}else{
				if (confirm("真的要删除吗？")){
					$.ajax({
					  type: "POST",
					  url: "deleteMenu",
					  cache: false,
					  data: 'ids='+ids+'&values='+values,
					  success: function(html){
					    if(html=="1"){
					    	for ( var int = 0; int < nodes.length; int++) {
								var node = nodes[int];
								$('#tt2').tree('remove', node.target);
							}
					    	alert("删除成功");
					    }else if(html=='2'){
					    	alert("删除失败：未知错误，请联系管理员");
					    }else{
					    	alert("删除出错："+html);
					    }
					  }
					});
				}
			}
		}
		function reload(){
			$('#tt2').tree('reload');
		}
	</script>
  </head>
<body style="background-color: white;height: 100%;"> 
	<div style="float: left;">
		<a href='javascript:deleteFile()'>删除</a>
		<a href='javascript:reload()'>刷新</a>
	</div>
	<div style="float: left;width: 100%;height: 100%;">
		<ul id="tt2" class="easyui-tree" data-options="url:'getMenu',onClick: function(node){
					$(this).tree('toggle', node.target);
				}" style="height: 97%;overflow: auto;">
		</ul>
	</div>
</body>
</html>
